export default {
  data() {
    return {
      // 所有菜单项
      menus: [],
      collapse: false,
      iconList: ['icon-users', 'icon-tijikongjian', 'icon-shangpin', 'icon-danju', 'icon-baobiao'],
      // 被激活的菜单path
      activePath: ''
    }
  },
  created() {
    this.getMens()
    this.activePath = window.sessionStorage.getItem('activePath')
  },
  methods: {
    logout() {
      // 退出登录状态
      window.sessionStorage.removeItem('token')
      this.$router.push('/login')
    },
    // 获取左侧菜单列表
    async getMens() {
      const { data: res } = await this.$http.get('menus')
      if (res.meta.status !== 200) return this.$message.error('获取失败')
      this.menus = res.data
    },
    saveActivePath(activePath) {
      // console.log(activePath)
      this.activePath = activePath
      // 保存的sessionStorage中
      window.sessionStorage.setItem('activePath', activePath)
    }
  }
}
